<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>卖车宝后台</title>
    <meta name="keywords" content="卖车宝后台">
    <meta name="description" content="卖车宝后台">

    <link rel="shortcut icon" href="favicon.ico"> <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <script>if(window.top !== window.self){ window.top.location = window.location;}</script>

</head>

<body class="gray-bg">

    <div class="middle-box text-center loginscreen   animated fadeInDown">
        <div>
            <div>

                <h1 class="logo-name">Car</h1>

            </div>
            <h3>欢迎注册 Car</h3>
            <p>创建一个Car新账户</p>
            <form class="m-t" role="form" onsubmit="return false">
                <div class="form-group">
                    <input id="userName" type="text" class="form-control" placeholder="请输入用户名" required="">
                </div>
                <div class="form-group">
                    <input id="password" type="password" class="form-control" placeholder="请输入密码" required="">
                </div>
                <div class="form-group">
                    <input id="confirmPassword"  type="password" class="form-control" placeholder="请再次输入密码" required="">
                </div>
                <div class="form-group text-left">
                    <div class="checkbox i-checks">
                        <label class="no-padding">
                            <input type="checkbox"><i></i> 我同意注册协议</label>
                    </div>
                </div>
                <button id="register" type="submit" class="btn btn-primary block full-width m-b">注 册</button>
                
                <p class="text-muted text-center"><small>已经有账户了？</small><a href="login_v2.html">点此登录</a>
                </p>

                                
            </form>
        </div>
    </div>

    <!-- 全局js -->
    <script src="js/jquery.min.js?v=2.1.4"></script>
    <script src="js/bootstrap.min.js?v=3.3.6"></script>
    <!-- iCheck -->
    <script src="js/plugins/iCheck/icheck.min.js"></script>
    
      <!-- 自定义js -->
	<script src="js/vue.min.js"></script>
	<script src="js/axios.min.js"></script>
	<script src="js/config/prefixConfig.js"></script>
    <script src="js/plugins/sweetalert/sweetalert.min.js"></script>
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
        
        $("#register").click(function (){
        	if($("#userName").val() == "" || $("#password").val() == "") {
				swal({
                    title: "温馨提示：",
                    text: "请完善信息！",
                    type: "success"
                });
                return;
			}
	    	if($("#password").val() != $("#confirmPassword").val()) {
	    		swal({
                    title: "请输入正确密码",
                    text: "密码不一致"
   		 		});
	    		return;
	    	} else {
				//注册
				var params = new URLSearchParams();
				params.append('userName', $("#userName").val());
				params.append('password', $("#password").val());
				postData("/wxc/userService/addUser", params).then((res)=> {
					if(res.data.resultCode == '1') {
						swal({
		                    title: "温馨提示：",
		                    text: "注册成功！",
		                    type: "success"
		                });
	    				return;
					} else {
                        swal("注册失败", res.data.content, "error");
	    				return;
					}
				}).catch((err)=> {
					console.log(err);
					swal({
	                    title: "服务器错误",
	                    text: err
           		 	});
	    			return;
				})
	    	}
       });
       
        
        /**
		 * get数据
		 * @param {Object} url
		 */
		function getData(url) {
			var prefix= new Prefix();
			api = prefix.getPrefix();
			let apiurl = api + url;
			return axios.get(apiurl);
		}
		
		/**
		 * post数据
		 * @param {Object} url
		 * @param {Object} data
		 */
		function postData(url, data) {
			var prefix= new Prefix();
			api = prefix.getPrefix();
			return axios.post(api + url, data)
		}
    </script>

    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <!--统计代码，可删除-->

</body>

</html>
